/****
 * Copyright (C) 2006 dNux Team
 *                                                            ****
 * This program is free software; you can redistribute it and/or *
 * modify under the terms of the GNU General Public License as   *
 * published by the Free Software Foundation;                    *
 * either version 2 of the License.                              *
 *                                                               *
 * This program is distributed in the hope that it will be       *
 * useful, but WITHOUT ANY WARRANTY; without even the implied    *
 * warranty of without even the implied waranty of               *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.          *
 * See the GNU General Public License for more details.          *
 *                                                               *
 * You should have received a copy of the                        *
 * GNU General Public License                                    *
 * along with this program; if not, write to the                 *
 * Free Software Foundation, Inc.,                               *
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. *
 *                                                               *
 ****                                                         ****/

#include "dcheck.h"

d_check_t *
d_check_new()
{
  d_check_t *check;

  check = (d_check_t *) malloc(sizeof(d_check_t));
  memset(check, 0, sizeof(d_check_t));
  
  return check;
}

void
d_check_free(d_check_t **check)
{
  if (*check) {
    free(*check);
  }
  *check = NULL;
}

void
d_check_add(d_check_t *check, d_check_result_t result, char *log)
{
  check->total++;
  switch(result) {
  case D_CHECK_OK:
    fprintf(stdout, "[OK] ");
    check->ok++;
    break;
  case D_CHECK_ERROR:
    fprintf(stdout, "[ERROR] ");
    check->error++;
    break;
  case D_CHECK_WARNING:
    fprintf(stdout, "[WARNING] ");
    check->warning++;
    break;
  default:
    fprintf(stdout, "[UNKNOWN] ");
    break;
  }
  fprintf(stdout, "%s\n", log);
}

void
d_check_result(d_check_t *check)
{
  fprintf(stdout, "\n-== Summary ==-\n");
  fprintf(stdout, "total   : %d\n", check->total);
  fprintf(stdout, "ok      : %d\n", check->ok);
  fprintf(stdout, "warning : %d\n", check->warning);
  fprintf(stdout, "error   : %d\n", check->error);

}
